package com.cxh.controller.Thread;

import java.util.ArrayList;
import java.util.Map;
import java.util.Set;

import com.cxh.util.AiuiUnit;

public class HttpThread{

	private String question;
	private String code;
	
	public void run() {
		try {
			AiuiUnit.loadAiuiApi(question, code);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public HttpThread(String question,String code) {
		this.question = question;
		this.code = code;
	}
	
	/*public synchronized static void createThreadPoor(String question,String code){
		
		//线程池 10核心线程数 200最大线程数 200非核心线程的闲置超时时间   MILLISECONDS单位 ArrayBlockingQueue线程池中的任务队列
		ThreadPoolExecutor executor = new ThreadPoolExecutor(20, 200, 200, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(5));
		executor.execute(new HttpThread(question,code));
		executor.shutdown();
	}*/

	public static void createThreadPoor(ArrayList<Map<String, String>> threadList) {
		ArrayList<HttpThread> arrayList = new ArrayList<HttpThread>();
		for (Map<String, String> map : threadList) {
			Set<String> keySet = map.keySet();
			for (String key : keySet) {
				String value = map.get(key);
				HttpThread httpThread = new HttpThread(key, value) ;
				arrayList.add(httpThread);
			}
		}
		for (HttpThread httpThread : arrayList) {
			httpThread.run();
		}
	}
	

}
